package com.fyl.log.aop;

import com.fyl.log.anno.AsyncLog;
import org.aopalliance.aop.Advice;
import org.springframework.aop.Pointcut;
import org.springframework.aop.support.AbstractPointcutAdvisor;
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;

public class AsyncLogAdvisor extends AbstractPointcutAdvisor {

    private Pointcut pointcut;

    private Advice advice;

    public AsyncLogAdvisor(Advice advice) {
        this.pointcut = buildPointcut();
        this.advice = advice;
    }

    @Override
    public Pointcut getPointcut() {
        return pointcut;
    }

    @Override
    public Advice getAdvice() {
        return advice;
    }

    private Pointcut buildPointcut() {
        // method
        return AnnotationMatchingPointcut.forMethodAnnotation(AsyncLog.class);
    }
}
